<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1,user-scalable=no">		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/font/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/plug-in/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/list-detail.css" />
    <script src="/public/static/wx/js/flex.js" type="text/javascript" charset="utf-8"></script>
    <title>任务信息</title>
    <style type="text/css">
        #layui-layer1{
            overflow: hidden;
        }

        .buttons a{
            width: 100%;
            height: 100%;
            color: #fff;
        }
        .layui-layer-btn a{
            font-size: 18px;
        }
        .layui-layer-content{
            font-size: 17px;
        }
    </style>
</head>

<body>
<div class="index">
    <ul class="list">
        <li class="clearfix">
            <p class="title">标题</p>
            <p class="content">{$info.title}</p>
        </li>
        <li class="clearfix">
            <p class="title">电话</p>
            <p class="content">{$info.tel}</p>
        </li>
        <li class="clearfix">
            <p class="title">地址</p>
            <p class="content">{$info.address}</p>
        </li>
        <li class="clearfix area">
            <p class="title">故障类型</p>
            <p class="content">{$info.fault_name}</p>
        </li>
        <li class="clearfix">
            <p class="title">描述</p>
            <p class="content">{$info.desc}</p>
        </li>
        <li class="clearfix">
            <p class="title">附件材料</p>
            <p class="content">
                {if condition=" !empty($info.attach)"}
                <a href="{$info.attach}" style="color: #009E94;">附件1</a>
                {/if}
                {if condition=" !empty($info.w_attach)"}
                <a href="{$info.w_attach}" style="color: #009E94;">附件2</a>
                {/if}
            </p>
        </li>

        <li class="clearfix">
            <p class="title">工具票</p>
            <p class="content">
                {volist name="$info.ticket" id="vo"}
                    {if condition=" !empty($vo)"}
                        <a href="{$vo}" style="color: #009E94;">文件</a>
                    {/if}
                {/volist}
            </p>
        </li>

        <li class="clearfix">
            <p class="title">创建时间</p>
            <p class="content">{$info.c_time}</p>
        </li>
        <li class="clearfix">
            <p class="title">状态</p>
            <p class="content">{$info.state_name}</p>
        </li>
        {if condition = "$info.state_id==23"}
         <li class="clearfix">
             <p class="title">拒单原因</p>
             <p class="content">{$info.reason}</p>
         </li>
        {/if}
    </ul>
    <!-- <ul class="buttons jiedan clearfix">
         <li class="refuse">选择工具</li>
         <li class="apply">工具列表</li>
         <li class="follow">跟踪状态</li>
     </ul>-->
    {if condition = "$info.state_id==22"}
    <ul class="buttons clearfix" style="display: flex;text-align: center;justify-content: center">
        <li class="add-follow" onclick="optBtn('r')">接单</li>
        <li class="follow" onclick="optBtn('f')">拒单</li>
    </ul>
    {/if}

    {if condition = "$info.state_id==21"}
    <ul class="buttons clearfix" style="display: flex;text-align: center;justify-content: center">
        <li class="add-follow" onclick="optBtn('s')">组建团队</li>
    </ul>
    {/if}

    {if condition = "$info.state_id==25"}
    <ul class="buttons clearfix" style="display: flex;text-align: center;justify-content: center">
        <li class="add-follow" onclick="optBtn('t')">团队人员</li>
        <li class="follow" onclick="optBtn('l')">跟踪状态</li>
    </ul>
    {/if}


    <!--<ul class="buttons clearfix" style="display: flex;text-align: center;justify-content: center">
        <li class="add-follow"><a href="{:url('sendThirdUI')}?id={$info.id}">派单</a></li>
        <li class="follow"><a href="{:url('trackUI')}?id={$info.id}">跟踪</a></li>
    </ul>-->
</div>

<script src="/public/static/wx/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/public/static/wx/plug-in/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
    var layer = layui.layer;
    $('.apply').on('click',function(){
        layer.open({
            type: 2,
            area: ['70%', '60%'],
            title: '可选工程师',
            content: 'choose-engineer.html',
            scrollbar:false,
            success: function(layero, index) {

            },
        });
    });


    var id = '{:input("id")}';
    function optBtn(k) {

        if(id.length<=0){
            layer.msg('页面信息异常，请返回重新登陆',{icon:5},function () {
                location.href = location.href+"&t";
            });
            return;
        }

        switch (k){
            case 'r':
                layer.confirm('确认接单吗?', {icon: 3, title:'提示',shadeClose:true}, function(index){

                    $.post('{:url("receipt")}',{dis_id:id},function (res) {
                        if(res.code==1){
                            layer.msg('接单成功',{icon:6,shade:0.1},function () {
                                location.href = location.href+"&t";
                            });
                        }else{
                            layer.msg(res.msg,{icon:5});
                        }
                    });

                    layer.close(index);
                });
                break;
            case 'f':
                layer.prompt({
                    formType: 2,
                    value: '',
                    title: '请输入拒绝原因',
                    area: ['300px', '200px'] //自定义文本域宽高
                }, function(value, index, elem){

                    $.post('{:url("refusal")}',{dis_id:id,val:value},function (res) {
                        if(res.code==1){
                            layer.msg(res.msg,{icon:6,shade:0.1},function () {
                                location.href = location.href+"&t";
                            });
                        }else{
                            layer.msg(res.msg,{icon:5});
                        }
                    });

                    layer.close(index);
                });
                break;
            case 's':
                location.href = '{:url("teamUI")}?id={:$info.id}&a=s';
                break;
            case 't':
                location.href = '{:url("teamUI")}?id={:$info.id}&a=t';
                break;
            case 'l':
                location.href = '{:url("trackUI")}?id={:$info.id}';
                break;
        }

    }

</script>
</body>

</html>